@echo off

rem Create local variable's stack
setlocal

if 0%__CTRL_SETLOCAL% EQU 1 (
  echo.%~nx0: error: cmd.exe is broken, please restart it!
  exit /b 65535
) >&2
set __CTRL_SETLOCAL=1

call "%%~dp0__init__/__init__.bat" || exit /b
call "%%CONTOOLS_TESTLIB_ROOT%%/init.bat" "%%~f0" || exit /b

setlocal
set "REFERENCE_1_VALUE_01="
set "REFERENCE_1_VALUE_02=	 "
set "REFERENCE_1_VALUE_03="
set "REFERENCE_1_VALUE_04=	 "
set  REFERENCE_1_VALUE_05=
set  REFERENCE_1_VALUE_06=""	 
set  REFERENCE_1_VALUE_07=	 ""
set  REFERENCE_1_VALUE_08=	 ""	 
set  REFERENCE_1_VALUE_09=	 ""
set  REFERENCE_1_VALUE_10=	 ""	 
call :TEST test_1_empty.vars TEST_1_VALUE_ REFERENCE_1_VALUE_ ^
  01 02 03 04 05 06 07 08 09 10
endlocal

setlocal
set "PARAM0="
set "PARAM1="

set "REFERENCE_2_VALUE_01=0"
set "REFERENCE_2_VALUE_02=	 0	 "
set  REFERENCE_2_VALUE_03=	 "0"	 
set "REFERENCE_2_VALUE_04=0"
set "REFERENCE_2_VALUE_05=	 0	 "
set  REFERENCE_2_VALUE_06=	 "0"	 

set "REFERENCE_2_VALUE_11=1"
set "REFERENCE_2_VALUE_12=	 1	 "
set  REFERENCE_2_VALUE_13=	 "1"	 
set "REFERENCE_2_VALUE_21="
set "REFERENCE_2_VALUE_22="
set "REFERENCE_2_VALUE_23="
set "REFERENCE_2_VALUE_31=3"
set "REFERENCE_2_VALUE_32=	 3	 "
set  REFERENCE_2_VALUE_33=	 "3"	 
set "REFERENCE_2_VALUE_41="
set "REFERENCE_2_VALUE_42="
set "REFERENCE_2_VALUE_43="

set "REFERENCE_2_VALUE_51="
set "REFERENCE_2_VALUE_52="
set "REFERENCE_2_VALUE_53="
set "REFERENCE_2_VALUE_61="
set "REFERENCE_2_VALUE_62="
set "REFERENCE_2_VALUE_63="
set "REFERENCE_2_VALUE_71="
set "REFERENCE_2_VALUE_72="
set "REFERENCE_2_VALUE_73="
set "REFERENCE_2_VALUE_81="
set "REFERENCE_2_VALUE_82="
set "REFERENCE_2_VALUE_83="

set "REFERENCE_2_VALUE_a1="
set "REFERENCE_2_VALUE_a2="
set "REFERENCE_2_VALUE_a3="
set "REFERENCE_2_VALUE_b1="
set "REFERENCE_2_VALUE_b2="
set "REFERENCE_2_VALUE_b3="
set "REFERENCE_2_VALUE_c1="
set "REFERENCE_2_VALUE_c2="
set "REFERENCE_2_VALUE_c3="
set "REFERENCE_2_VALUE_d1="
set "REFERENCE_2_VALUE_d2="
set "REFERENCE_2_VALUE_d3="
set "REFERENCE_2_VALUE_e1="
set "REFERENCE_2_VALUE_e2="
set "REFERENCE_2_VALUE_e3="

call :TEST test_2_conditional.vars TEST_2_VALUE_ REFERENCE_2_VALUE_ ^
  01 02 03 04 05 06  11 12 13  21 22 23  31 32 33  41 42 43  51 52 53  61 62 63  71 72 73  81 82 83 ^
  a1 a2 a3  b1 b2 b3  c1 c2 c3  d1 d2 d3  e1 e2 e3
endlocal

setlocal
set "PARAM0=P0"
set "PARAM1="

set "REFERENCE_2_VALUE_01=0"
set "REFERENCE_2_VALUE_02=	 0	 "
set  REFERENCE_2_VALUE_03=	 "0"	 
set "REFERENCE_2_VALUE_04=0"
set "REFERENCE_2_VALUE_05=	 0	 "
set  REFERENCE_2_VALUE_06=	 "0"	 

set "REFERENCE_2_VALUE_11=1"
set "REFERENCE_2_VALUE_12=	 1	 "
set  REFERENCE_2_VALUE_13=	 "1"	 
set "REFERENCE_2_VALUE_21="
set "REFERENCE_2_VALUE_22="
set "REFERENCE_2_VALUE_23="
set "REFERENCE_2_VALUE_31=3"
set "REFERENCE_2_VALUE_32=	 3	 "
set  REFERENCE_2_VALUE_33=	 "3"	 
set "REFERENCE_2_VALUE_41="
set "REFERENCE_2_VALUE_42="
set "REFERENCE_2_VALUE_43="

set "REFERENCE_2_VALUE_51="
set "REFERENCE_2_VALUE_52="
set "REFERENCE_2_VALUE_53="
set "REFERENCE_2_VALUE_61="
set "REFERENCE_2_VALUE_62="
set "REFERENCE_2_VALUE_63="
set "REFERENCE_2_VALUE_71="
set "REFERENCE_2_VALUE_72="
set "REFERENCE_2_VALUE_73="
set "REFERENCE_2_VALUE_81="
set "REFERENCE_2_VALUE_82="
set "REFERENCE_2_VALUE_83="

set "REFERENCE_2_VALUE_a1="
set "REFERENCE_2_VALUE_a2="
set "REFERENCE_2_VALUE_a3="
set "REFERENCE_2_VALUE_b1="
set "REFERENCE_2_VALUE_b2="
set "REFERENCE_2_VALUE_b3="
set "REFERENCE_2_VALUE_c1=3"
set "REFERENCE_2_VALUE_c2=	 3	 "
set  REFERENCE_2_VALUE_c3=	 "3"	 
set "REFERENCE_2_VALUE_d1="
set "REFERENCE_2_VALUE_d2="
set "REFERENCE_2_VALUE_d3="
set "REFERENCE_2_VALUE_e1="
set "REFERENCE_2_VALUE_e2="
set "REFERENCE_2_VALUE_e3="

call :TEST test_2_conditional.vars TEST_2_VALUE_ REFERENCE_2_VALUE_ ^
  01 02 03 04 05 06  11 12 13  21 22 23  31 32 33  41 42 43  51 52 53  61 62 63  71 72 73  81 82 83 ^
  a1 a2 a3  b1 b2 b3  c1 c2 c3  d1 d2 d3  e1 e2 e3
endlocal

setlocal
set "PARAM0="
set "PARAM1=P1"

set "REFERENCE_2_VALUE_01=0"
set "REFERENCE_2_VALUE_02=	 0	 "
set  REFERENCE_2_VALUE_03=	 "0"	 
set "REFERENCE_2_VALUE_04=0"
set "REFERENCE_2_VALUE_05=	 0	 "
set  REFERENCE_2_VALUE_06=	 "0"	 

set "REFERENCE_2_VALUE_11=1"
set "REFERENCE_2_VALUE_12=	 1	 "
set  REFERENCE_2_VALUE_13=	 "1"	 
set "REFERENCE_2_VALUE_21="
set "REFERENCE_2_VALUE_22="
set "REFERENCE_2_VALUE_23="
set "REFERENCE_2_VALUE_31=3"
set "REFERENCE_2_VALUE_32=	 3	 "
set  REFERENCE_2_VALUE_33=	 "3"	 
set "REFERENCE_2_VALUE_41="
set "REFERENCE_2_VALUE_42="
set "REFERENCE_2_VALUE_43="

set "REFERENCE_2_VALUE_51=1"
set "REFERENCE_2_VALUE_52=	 1	 "
set  REFERENCE_2_VALUE_53=	 "1"	 
set "REFERENCE_2_VALUE_61="
set "REFERENCE_2_VALUE_62="
set "REFERENCE_2_VALUE_63="
set "REFERENCE_2_VALUE_71=3"
set "REFERENCE_2_VALUE_72=	 3	 "
set  REFERENCE_2_VALUE_73=	 "3"	 
set "REFERENCE_2_VALUE_81="
set "REFERENCE_2_VALUE_82="
set "REFERENCE_2_VALUE_83="

set "REFERENCE_2_VALUE_a1="
set "REFERENCE_2_VALUE_a2="
set "REFERENCE_2_VALUE_a3="
set "REFERENCE_2_VALUE_b1=2"
set "REFERENCE_2_VALUE_b2=	 2	 "
set  REFERENCE_2_VALUE_b3=	 "2"	 
set "REFERENCE_2_VALUE_c1="
set "REFERENCE_2_VALUE_c2="
set "REFERENCE_2_VALUE_c3="
set "REFERENCE_2_VALUE_d1="
set "REFERENCE_2_VALUE_d2="
set "REFERENCE_2_VALUE_d3="
set "REFERENCE_2_VALUE_e1="
set "REFERENCE_2_VALUE_e2="
set "REFERENCE_2_VALUE_e3="

call :TEST test_2_conditional.vars TEST_2_VALUE_ REFERENCE_2_VALUE_ ^
  01 02 03 04 05 06  11 12 13  21 22 23  31 32 33  41 42 43  51 52 53  61 62 63  71 72 73  81 82 83 ^
  a1 a2 a3  b1 b2 b3  c1 c2 c3  d1 d2 d3  e1 e2 e3
endlocal

setlocal
set "PARAM0=P0"
set "PARAM1=P1"

set "REFERENCE_2_VALUE_01=0"
set "REFERENCE_2_VALUE_02=	 0	 "
set  REFERENCE_2_VALUE_03=	 "0"	 
set "REFERENCE_2_VALUE_04=0"
set "REFERENCE_2_VALUE_05=	 0	 "
set  REFERENCE_2_VALUE_06=	 "0"	 

set "REFERENCE_2_VALUE_11=1"
set "REFERENCE_2_VALUE_12=	 1	 "
set  REFERENCE_2_VALUE_13=	 "1"	 
set "REFERENCE_2_VALUE_21="
set "REFERENCE_2_VALUE_22="
set "REFERENCE_2_VALUE_23="
set "REFERENCE_2_VALUE_31=3"
set "REFERENCE_2_VALUE_32=	 3	 "
set  REFERENCE_2_VALUE_33=	 "3"	 
set "REFERENCE_2_VALUE_41="
set "REFERENCE_2_VALUE_42="
set "REFERENCE_2_VALUE_43="

set "REFERENCE_2_VALUE_51=1"
set "REFERENCE_2_VALUE_52=	 1	 "
set  REFERENCE_2_VALUE_53=	 "1"	 
set "REFERENCE_2_VALUE_61="
set "REFERENCE_2_VALUE_62="
set "REFERENCE_2_VALUE_63="
set "REFERENCE_2_VALUE_71=3"
set "REFERENCE_2_VALUE_72=	 3	 "
set  REFERENCE_2_VALUE_73=	 "3"	 
set "REFERENCE_2_VALUE_81="
set "REFERENCE_2_VALUE_82="
set "REFERENCE_2_VALUE_83="

set "REFERENCE_2_VALUE_a1=1"
set "REFERENCE_2_VALUE_a2=	 1	 "
set  REFERENCE_2_VALUE_a3=	 "1"	 
set "REFERENCE_2_VALUE_b1=2"
set "REFERENCE_2_VALUE_b2=	 2	 "
set  REFERENCE_2_VALUE_b3=	 "2"	 
set "REFERENCE_2_VALUE_c1=3"
set "REFERENCE_2_VALUE_c2=	 3	 "
set  REFERENCE_2_VALUE_c3=	 "3"	 
set "REFERENCE_2_VALUE_d1="
set "REFERENCE_2_VALUE_d2="
set "REFERENCE_2_VALUE_d3="
set "REFERENCE_2_VALUE_e1="
set "REFERENCE_2_VALUE_e2="
set "REFERENCE_2_VALUE_e3="

call :TEST test_2_conditional.vars TEST_2_VALUE_ REFERENCE_2_VALUE_ ^
  01 02 03 04 05 06  11 12 13  21 22 23  31 32 33  41 42 43  51 52 53  61 62 63  71 72 73  81 82 83 ^
  a1 a2 a3  b1 b2 b3  c1 c2 c3  d1 d2 d3  e1 e2 e3
endlocal

setlocal DISABLEDELAYEDEXPANSION
set "TEST_3_VALUE_00="

set "REFERENCE_3_VALUE_011="
set "REFERENCE_3_VALUE_012=	 	 "
set  REFERENCE_3_VALUE_013=	 ""	 
set "REFERENCE_3_VALUE_021=%%"
set "REFERENCE_3_VALUE_022=	 %%	 "
set  REFERENCE_3_VALUE_023=	 "%%"	 
set "REFERENCE_3_VALUE_031=%%"
set "REFERENCE_3_VALUE_032=	 %%	 "
set  REFERENCE_3_VALUE_033=	 "%%"	 
set "REFERENCE_3_VALUE_041=%%%%"
set "REFERENCE_3_VALUE_042=	 %%%%	 "
set  REFERENCE_3_VALUE_043=	 "%%%%"	 
set "REFERENCE_3_VALUE_051="
set "REFERENCE_3_VALUE_052=	 	 "
set  REFERENCE_3_VALUE_053=	 ""	 
set "REFERENCE_3_VALUE_061=%% "
set "REFERENCE_3_VALUE_062=	 %% 	 "
set  REFERENCE_3_VALUE_063=	 "%% "	 
set "REFERENCE_3_VALUE_071="
set "REFERENCE_3_VALUE_072=	 	 "
set  REFERENCE_3_VALUE_073=	 ""	 
set "REFERENCE_3_VALUE_081=X"
set "REFERENCE_3_VALUE_082=	 X	 "
set  REFERENCE_3_VALUE_083=	 "X"	 
set "REFERENCE_3_VALUE_091=X"
set "REFERENCE_3_VALUE_092=	 X	 "
set  REFERENCE_3_VALUE_093=	 "X"	 
set "REFERENCE_3_VALUE_101="
set "REFERENCE_3_VALUE_102=	 	 "
set  REFERENCE_3_VALUE_103=	 ""	 
set "REFERENCE_3_VALUE_111=%%X%%"
set "REFERENCE_3_VALUE_112=	 %%X%%	 "
set  REFERENCE_3_VALUE_113=	 "%%X%%"	 

set "REFERENCE_3_VALUE_a01="
set "REFERENCE_3_VALUE_a02=	 	 "
set  REFERENCE_3_VALUE_a03=	 ""	 
set "REFERENCE_3_VALUE_b01="
set "REFERENCE_3_VALUE_b02=	 	 "
set  REFERENCE_3_VALUE_b03=	 ""	 
set "REFERENCE_3_VALUE_c01=%%TEST_3_VALUE_000"
set "REFERENCE_3_VALUE_c02=	 %%TEST_3_VALUE_000	 "
set  REFERENCE_3_VALUE_c03=	 "%%TEST_3_VALUE_000"	 
set "REFERENCE_3_VALUE_d01="
set "REFERENCE_3_VALUE_d02=	 	 "
set  REFERENCE_3_VALUE_d03=	 ""	 
set "REFERENCE_3_VALUE_e01=%%"
set "REFERENCE_3_VALUE_e02=	 %%	 "
set  REFERENCE_3_VALUE_e03=	 "%%"	 
set "REFERENCE_3_VALUE_f01=%%TEST_3_VALUE_000%%"
set "REFERENCE_3_VALUE_f02=	 %%TEST_3_VALUE_000%%	 "
set  REFERENCE_3_VALUE_f03=	 "%%TEST_3_VALUE_000%%"	 

set "REFERENCE_3_VALUE_g01=%"
set "REFERENCE_3_VALUE_g02=	 	 	 	 "
set  REFERENCE_3_VALUE_g03=	 "	 ""	 "	 
set "REFERENCE_3_VALUE_h01="
set "REFERENCE_3_VALUE_h02=	 	 	 	 	 	 
set  REFERENCE_3_VALUE_h03=	 "	 ""	 	 ""	 "	 
set "REFERENCE_3_VALUE_i01=%%TEST_3_VALUE_011"
set "REFERENCE_3_VALUE_i02=	 	 	 %%TEST_3_VALUE_012	 "
set  REFERENCE_3_VALUE_i03=	 "	 ""	 %%TEST_3_VALUE_013"	 
set "REFERENCE_3_VALUE_j01="
set "REFERENCE_3_VALUE_j02=	 	 	 	 
set  REFERENCE_3_VALUE_j03=	 "	 ""	 "	 
set "REFERENCE_3_VALUE_k01=%%"
set "REFERENCE_3_VALUE_k02=	 	 	 %%	 "
set  REFERENCE_3_VALUE_k03=	 "	 ""	 %%"	 
set "REFERENCE_3_VALUE_l01=%%TEST_3_VALUE_011%%"
set "REFERENCE_3_VALUE_l02=	 %%TEST_3_VALUE_012%%	 "
set  REFERENCE_3_VALUE_l03=	 "%%TEST_3_VALUE_013%%"	 

rem ---

set "REFERENCE_3_VALUE_211=!"
set "REFERENCE_3_VALUE_212=	 !	 "
set  REFERENCE_3_VALUE_213=	 "!"	 
set "REFERENCE_3_VALUE_221=!!"
set "REFERENCE_3_VALUE_222=	 !!	 "
set  REFERENCE_3_VALUE_223=	 "!!"	 
set "REFERENCE_3_VALUE_231=!!!"
set "REFERENCE_3_VALUE_232=	 !!!	 "
set  REFERENCE_3_VALUE_233=	 "!!!"	 
set "REFERENCE_3_VALUE_241=!!!!"
set "REFERENCE_3_VALUE_242=	 !!!!	 "
set  REFERENCE_3_VALUE_243=	 "!!!!"	 
set "REFERENCE_3_VALUE_251=! !"
set "REFERENCE_3_VALUE_252=	 ! !	 "
set  REFERENCE_3_VALUE_253=	 "! !"	 
set "REFERENCE_3_VALUE_261=!! !"
set "REFERENCE_3_VALUE_262=	 !! !	 "
set  REFERENCE_3_VALUE_263=	 "!! !"	 
set "REFERENCE_3_VALUE_271=! !!"
set "REFERENCE_3_VALUE_272=	 ! !!	 "
set  REFERENCE_3_VALUE_273=	 "! !!"	 
set "REFERENCE_3_VALUE_281=!X"
set "REFERENCE_3_VALUE_282=	 !X	 "
set  REFERENCE_3_VALUE_283=	 "!X"	 
set "REFERENCE_3_VALUE_291=X!"
set "REFERENCE_3_VALUE_292=	 X!	 "
set  REFERENCE_3_VALUE_293=	 "X!"	 
set "REFERENCE_3_VALUE_301=!X!"
set "REFERENCE_3_VALUE_302=	 !X!	 "
set  REFERENCE_3_VALUE_303=	 "!X!"	 
set "REFERENCE_3_VALUE_311=!!X!!"
set "REFERENCE_3_VALUE_312=	 !!X!!	 "
set  REFERENCE_3_VALUE_313=	 "!!X!!"	 

set "REFERENCE_3_VALUE_a11=!TEST_3_VALUE_000!"
set "REFERENCE_3_VALUE_a12=	 !TEST_3_VALUE_000!	 "
set  REFERENCE_3_VALUE_a13=	 "!TEST_3_VALUE_000!"	 
set "REFERENCE_3_VALUE_b11=!TEST_3_VALUE_000!!TEST_3_VALUE_000!"
set "REFERENCE_3_VALUE_b12=	 !TEST_3_VALUE_000!!TEST_3_VALUE_000!	 "
set  REFERENCE_3_VALUE_b13=	 "!TEST_3_VALUE_000!!TEST_3_VALUE_000!"	 
set "REFERENCE_3_VALUE_c11=!TEST_3_VALUE_000!!!TEST_3_VALUE_000!"
set "REFERENCE_3_VALUE_c12=	 !TEST_3_VALUE_000!!!TEST_3_VALUE_000!	 "
set  REFERENCE_3_VALUE_c13=	 "!TEST_3_VALUE_000!!!TEST_3_VALUE_000!"	 
set "REFERENCE_3_VALUE_d11=!TEST_3_VALUE_000!!"
set "REFERENCE_3_VALUE_d12=	 !TEST_3_VALUE_000!!	 "
set  REFERENCE_3_VALUE_d13=	 "!TEST_3_VALUE_000!!"	 
set "REFERENCE_3_VALUE_e11=!TEST_3_VALUE_000!!!"
set "REFERENCE_3_VALUE_e12=	 !TEST_3_VALUE_000!!!	 "
set  REFERENCE_3_VALUE_e13=	 "!TEST_3_VALUE_000!!!"	 
set "REFERENCE_3_VALUE_f11=!!TEST_3_VALUE_000!!"
set "REFERENCE_3_VALUE_f12=	 !!TEST_3_VALUE_000!!	 "
set  REFERENCE_3_VALUE_f13=	 "!!TEST_3_VALUE_000!!"	 

set "REFERENCE_3_VALUE_g11=!"
set "REFERENCE_3_VALUE_g12=	 	 !	 	 "
set  REFERENCE_3_VALUE_g13=	 "	 "!"	 "	 
set "REFERENCE_3_VALUE_h11=!!"
set "REFERENCE_3_VALUE_h12=	 	 !	 	 !	 	 "
set  REFERENCE_3_VALUE_h13=	 "	 "!"	 	 "!"	 "	 
set "REFERENCE_3_VALUE_i11=!!!"
set "REFERENCE_3_VALUE_i12=	 	 !	 !	 !	 	 "
set  REFERENCE_3_VALUE_i13=	 "	 "!"	 !	 "!"	 "	 
set "REFERENCE_3_VALUE_j11=!!"
set "REFERENCE_3_VALUE_j12=	 	 !	 !	 "
set  REFERENCE_3_VALUE_j13=	 "	 "!"	 !"	 
set "REFERENCE_3_VALUE_k11=!!!"
set "REFERENCE_3_VALUE_k12=	 	 !	 !!	 "
set  REFERENCE_3_VALUE_k13=	 "	 "!"	 !!"	 
set "REFERENCE_3_VALUE_l11=!!!"
set "REFERENCE_3_VALUE_l12=	 !	 !	 !	 "
set  REFERENCE_3_VALUE_l13=	 "!	 "!"	 !"	 

call :TEST test_3_substitution.vars TEST_3_VALUE_ REFERENCE_3_VALUE_ ^
  011 012 013  021 022 023  031 032 033  041 042 043  051 052 053  061 062 063 ^
  071 072 073  081 082 083  091 092 093  101 102 103  111 112 113 ^
  a01 a02 a03  b01 b02 b03  c01 c02 c03  d01 d02 d03  e01 e02 e03  f01 f02 f03 ^
  g01 g02 g03  h01 h02 h03  i01 i02 i03  j01 j02 j03  k01 k02 k03  l01 l02 l03 ^
  211 212 213  221 222 223  231 232 233  241 242 243  251 252 253  261 262 263 ^
  271 272 273  281 282 283  291 292 293  301 302 303  311 312 313 ^
  a11 a12 a13  b11 b12 b13  c11 c12 c13  d11 d12 d13  e11 e12 e13  f11 f12 f13 ^
  g11 g12 g13  h11 h12 h13  i11 i12 i13  j11 j12 j13  k11 k12 k13  l11 l12 l13 ^
endlocal

setlocal
set  REFERENCE_4_VALUE_01=^"
set  REFERENCE_4_VALUE_02=	 "	 
set  REFERENCE_4_VALUE_03=	 """	 
set  REFERENCE_4_VALUE_11=%%"
set  REFERENCE_4_VALUE_12=	 %%"	 
set  REFERENCE_4_VALUE_13=	 "%%""	 
set "REFERENCE_4_VALUE_21="
set "REFERENCE_4_VALUE_22=	 	 
set  REFERENCE_4_VALUE_23=	 ""	 
set "REFERENCE_4_VALUE_31="
set  REFERENCE_4_VALUE_32=	 	 
set  REFERENCE_4_VALUE_33=	 ""	 
set  REFERENCE_4_VALUE_41=%%""
set  REFERENCE_4_VALUE_42=	 %%""	 
set  REFERENCE_4_VALUE_43=	 "%%"""	 
set  REFERENCE_4_VALUE_51=^^
set  REFERENCE_4_VALUE_52=	 ^^	 
set  REFERENCE_4_VALUE_53=	 "^"	 
set  REFERENCE_4_VALUE_61=^^^^
set  REFERENCE_4_VALUE_62=	 ^^^^	 
set  REFERENCE_4_VALUE_63=	 "^^"	 
set "REFERENCE_4_VALUE_71=\"
set "REFERENCE_4_VALUE_72=	 \	 "
set  REFERENCE_4_VALUE_73=	 "\"	 
set "REFERENCE_4_VALUE_81=\\"
set "REFERENCE_4_VALUE_82=	 \\	 "
set  REFERENCE_4_VALUE_83=	 "\\"	 
set  REFERENCE_4_VALUE_91=^"
set  REFERENCE_4_VALUE_92=	 "	 
set  REFERENCE_4_VALUE_93=	 """	 
set "REFERENCE_4_VALUE_101="
set  REFERENCE_4_VALUE_102=	 ""	 
set  REFERENCE_4_VALUE_103=	 """"	 

call :TEST test_4_escape.vars TEST_4_VALUE_ REFERENCE_4_VALUE_ ^
  01 02 03  11 12 13  21 22 23  31 32 33  41 42 43  51 52 53  61 62 63  71 72 73  81 82 83  91 92 93  101 102 103
endlocal

setlocal
set "REFERENCE_5_VALUE_00=#"
set "REFERENCE_5_VALUE_01=#	 "
set "REFERENCE_5_VALUE_02=	 #"
set "REFERENCE_5_VALUE_03=#"
set "REFERENCE_5_VALUE_04=	 #"
set  REFERENCE_5_VALUE_05=#""
set  REFERENCE_5_VALUE_06="" #
set  REFERENCE_5_VALUE_07=	 #""
set  REFERENCE_5_VALUE_08=	 "" #
set  REFERENCE_5_VALUE_09=	 ""#""	 
call :TEST test_5_commentary.vars TEST_5_VALUE_ REFERENCE_5_VALUE_ ^
  00 01 02 03 04 05 06 07 08 09
endlocal

setlocal
set "REFERENCE_6_VALUE_00="
set "REFERENCE_6_VALUE_01=1"
set "REFERENCE_6_VALUE_02==1"
set "REFERENCE_6_VALUE_03=	 =1	 1	 "
set "REFERENCE_6_VALUE_04= 1	 1	 "
set "REFERENCE_6_VALUE_05== 1	 1	 "
set "REFERENCE_6_VALUE_06=	 1	 ==	 "
set "REFERENCE_6_VALUE_07=="
set "REFERENCE_6_VALUE_08=	 "
set  REFERENCE_6_VALUE_09='	 "
set  REFERENCE_6_VALUE_10="	 '
set "REFERENCE_6_VALUE_11='	 '"
call :TEST test_6_specific.vars TEST_6_VALUE_ REFERENCE_6_VALUE_ ^
  00 01 02 03 04 05 06 07 08 09 10 11
endlocal

setlocal
set "TEST_7_VALUE_01=XXX"
set "TEST_7_VALUE_11=XXX"

set "REFERENCE_7_VALUE_01=XXX"
set "REFERENCE_7_VALUE_02=BBB"
set "REFERENCE_7_VALUE_11=XXX"
set "REFERENCE_7_VALUE_12=DDD"

call :TEST test_7_once.vars TEST_7_VALUE_ REFERENCE_7_VALUE_ ^
  01 02 11 12
endlocal

setlocal
set "REFERENCE_8_VALUE_01=AAA\BBB"
set "REFERENCE_8_VALUE_02=BBB\CCC"
set "REFERENCE_8_VALUE_11=AAA/BBB/CCC/DDD"
set "REFERENCE_8_VALUE_12=BBB/CCC/DDD/EEE"
set "REFERENCE_8_VALUE_21=AAA/BBB/CCC/DDD"
set "REFERENCE_8_VALUE_22=BBB/CCC/DDD/EEE"

call :TEST test_8_upath.vars TEST_8_VALUE_ REFERENCE_8_VALUE_ ^
  01 02 11 12 21 22
endlocal

setlocal
set "TEST_9_VALUE_02=x"
set "TEST_9_VALUE_03=x"
set "TEST_9_VALUE_04=x"

set "REFERENCE_9_VALUE_01=123 456/abc efg"
set "REFERENCE_9_VALUE_02=x"
set "REFERENCE_9_VALUE_03=x"
set "REFERENCE_9_VALUE_04=x"
set "REFERENCE_9_VALUE_05=;!COMSPEC!^="
set "REFERENCE_9_VALUE_06="
set "REFERENCE_9_VALUE_07="
set "REFERENCE_9_VALUE_08="
set "REFERENCE_9_VALUE_09=!"
set "REFERENCE_9_VALUE_10=!"
set "REFERENCE_9_VALUE_11="
set "REFERENCE_9_VALUE_12=!!"

set REFERENCE_9_VALUE_a1=1 ! 2 ^| 3 ^& 4 ^^ 5 = 6 , 7 ; 8 * 9 # 0 %% 1 / 2 \ 3 ? 4 ^> 5 ^< 6 " 7
set REFERENCE_9_VALUE_a2=	 1 ! 2 ^| 3 ^& 4 ^^ 5 = 6 , 7 ; 8 * 9 # 0 %% 1 / 2 \ 3 ? 4 ^> 5 ^< 6 " 7 	
set REFERENCE_9_VALUE_a3=	 1 ! 2 ^| 3 ^& 4 ^^ 5 = 6 , 7 ; 8 * 9 # 0 %% 1 / 2 \ 3 ? 4 ^> 5 ^< 6 " 7 	

call :TEST test_9_mixed.vars TEST_9_VALUE_ REFERENCE_9_VALUE_ ^
  01 02 03 04 05 06 07 08 09 10 11 12  a1 a2 a3
endlocal

echo.

rem WARNING: must be called without the call prefix!
"%CONTOOLS_TESTLIB_ROOT%/exit.bat"

rem no code can be executed here, just in case
exit /b

:TEST
echo.%~1...
call "%%CONTOOLS_TESTLIB_ROOT%%/test.bat" %%*
exit /b
